<template>
<div>
  <h1>添加管理员</h1>
<van-field label="添加名称" v-model="form.name"/>
  <select name="" id="" v-model="form.role_id">
    <option :value="i.id" v-for="i in list">{{i.name}}</option>
  </select>
  <van-button @click="add_admin">添加</van-button>


</div>
</template>

<script>
export default {
  name: "admin_users",
  data(){
    return{
      form:{},
      list:[]
    }
  },
  methods:{
    show_admin(){
      this.$axios.get('admin/adminUser')
        .then(i=>{
          this.list = i.data.list
        })
    },
    add_admin(){
      this.$axios.post('admin/adminUser',this.form)
      .then(i=>{
        if (i.data.code==200){
          alert('添加成功')
          this.form={}
        }
      })

    }
  },
  mounted() {
    this.show_admin()
  }
}
</script>

<style scoped>

</style>
